import {ElNotification} from "element-plus";

/**
 * 封装消息提示
 */
function msg(res:any,content:any){
    if (res.code===200){
        ElNotification({
            title: "提示",
            message: content.length>=1? content:res.msg,
            type: 'success',
        })
    }else {
        ElNotification({
            title: "提示",
            message: content.length>=1? content:res.msg,
            type: 'error',
        })
    }
}

export{msg}


/**
 * 判断空值方法
 */
export function isEmpty(value:any) {
    return value === null || value === undefined || value === '' || value==="" || value.length<=0;
}

/**
 * 字典状态转换
 * @param list
 * @param code
 */

export function dictStatus(list:any,code:any){
    let name = ''
    list.map((item:any)=>{
        if (String(item.code)===String(code)){
            name=item.name;
        }
    })
    return name;
}


/**
 * 视频时间格式转秒数
 * @param time
 */
export function convertToSeconds(time:any) {
    const parts = time.split(':');
    let seconds = 0;
    if (parts.length === 3) {
        seconds += parseInt(parts[0]) * 3600;
        seconds += parseInt(parts[1]) * 60;
    } else if (parts.length === 2) {
        seconds += parseInt(parts[0]) * 60;
    }
    seconds += parseInt(parts[parts.length - 1]);
    return seconds;
}
